<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>JS寄生组合式继承</title>
	<script type="text/javascript">
		function lastGeneration(name){
			this.name= name;
			this.property=['long',7,true];
		}
		//父类的属性
		lastGeneration.prototype.sayName= function(){
			alert(this.name);
		}
		//定义在父类原型中的方法
		function nextGeneration(name,age){
			lastGeneration.call(this,name);
			this.age=age;
		}
		function inherit(last,next){	//构造继承函数
			var prototype =last.prototype;			//创建对象
			prototype.constructor = next;					//增强对象
			next.prototype = prototype;						//指定对象
		}											
		inherit(lastGeneration,nextGeneration);
		//通过构造了一个继承函数，将父类的属性和方法继承给了子类又避免了属性的无效重写
		nextGeneration.sayAge= function(){
			alert(this.age);
		}
		var s1 = new nextGeneration();
		alert(s1.property);







	</script>
</head>
<body>
	
</body>
</html>